//
//  BoundDeviceViewModel.swift
//  EarbudsFunctions
//
//  Created by 李然 on 2024/4/27.
//

import Foundation
import RxSwift
import RxCocoa

public class BoundDeviceViewModel: ViewModel {
    
    public let device: Device
    
    public init(device: Device) {
        self.device = device
        super.init()
        
        connect.subscribe(onNext: { [weak self] _ in
            guard let `self` = self else { return }
            guard let discovery = device.discovery else { return }
            BluetoothManager.shared.interrupScan()
            BluetoothManager.shared.connect(discovery)
        }).disposed(by: rx.disposeBag)
    }
    
    // 连接事件
    public let connect = PublishRelay<Void>()
    
}
